<template>
    <div class="h-full flex flex-col bg-gray-500">
        <div class="w-full h-full flex justify-center items-center">
            <div class="w-full flex flex-col gap-y-1 m-4">
                <van-field v-model="state.code" placeholder="免登码" />
                <van-button type="primary" block @click="onSubmit">登录</van-button>
            </div>
        </div>
    </div>
</template>
<script setup>
import { useRouter } from 'vue-router'
import { getUserInfo } from '../../javascript/request/dingtalk'
let state = reactive({
    code: undefined,
    store: useStore(),
    router: useRouter(),
})

const onSubmit = () => {
    if (!state.code) return
    getUserInfo(state.code, true).then(res => {
        state.router.replace('/')
    })
}
const {} = toRefs(state)
</script>
